#Title: Appendix 6  Occam’s Razor
#Date: 19th Sept 2024

```{r preparation}
library(tidyverse)

library(plm)
library(modelsummary)

dat <- read.csv("D:/Essex_PhD/3rd_year/Data for R&R/Replication_R1_20240918/replication_20231015.csv") 
unique(dat$gwno)
```


```{r No Angola}

dat_no_Angola <-  dat %>%
  filter(!gwno == 540)

no_Angola.1 <- plm(log_osv_forward1 ~ treat_pko + treat_aid + 
                     treat_pko*treat_aid +
                     lnpop + prec_gpcp + conflict_intensity + 
                     spatial_lag_osv + spatial_lag_pko +
                     task_tamm + humaid_assist_tamm,
                     data = dat_no_Angola,
                         index = c("gid", "year"), model = "within")


no_Angola.2 <- plm(osv_binary_forward1 ~ treat_pko + treat_aid + 
                        treat_pko*treat_aid +
                     lnpop + prec_gpcp + conflict_intensity + 
                     spatial_lag_osv + spatial_lag_pko + 
                     task_tamm + humaid_assist_tamm,
                     data = dat_no_Angola,
                         index = c("gid", "year"), model = "within")

```

```{r No Burundi}
dat_no_Burundi <-  dat %>%
  filter(!gwno == 516)

no_Burundi.1 <- plm(log_osv_forward1 ~ treat_pko + treat_aid + 
                     treat_pko*treat_aid +
                     lnpop + prec_gpcp + conflict_intensity + 
                     spatial_lag_osv + spatial_lag_pko +
                     task_tamm + humaid_assist_tamm,
                   data = dat_no_Burundi,
                   index = c("gid", "year"), model = "within")


no_Burundi.2 <- plm(osv_binary_forward1 ~ treat_pko + treat_aid + 
                     treat_pko*treat_aid +
                     lnpop + prec_gpcp + conflict_intensity + 
                     spatial_lag_osv + spatial_lag_pko + 
                     task_tamm + humaid_assist_tamm,
                   data = dat_no_Burundi,
                   index = c("gid", "year"), model = "within")


```


```{r No DRC}

dat_no_DRC <-  dat %>%
  filter(!gwno == 490)

no_DRC.1 <- plm(log_osv_forward1 ~ treat_pko + treat_aid + 
                     treat_pko*treat_aid +
                     lnpop + prec_gpcp + conflict_intensity + 
                     spatial_lag_osv + spatial_lag_pko +
                     task_tamm + humaid_assist_tamm,
                   data = dat_no_DRC,
                   index = c("gid", "year"), model = "within")


no_DRC.2 <- plm(osv_binary_forward1 ~ treat_pko + treat_aid + 
                     treat_pko*treat_aid +
                     lnpop + prec_gpcp + conflict_intensity + 
                     spatial_lag_osv + spatial_lag_pko + 
                     task_tamm + humaid_assist_tamm,
                   data = dat_no_DRC,
                   index = c("gid", "year"), model = "within")

```



```{r No IvoryCoast}

dat_no_IvoryCoast <-  dat %>%
  filter(!gwno == 437)

no_IvoryCoast.1 <- plm(log_osv_forward1 ~ treat_pko + treat_aid + 
                     treat_pko*treat_aid +
                     lnpop + prec_gpcp + conflict_intensity + 
                     spatial_lag_osv + spatial_lag_pko +
                     task_tamm + humaid_assist_tamm,
                   data = dat_no_IvoryCoast,
                   index = c("gid", "year"), model = "within")


no_IvoryCoast.2 <- plm(osv_binary_forward1 ~ treat_pko + treat_aid + 
                     treat_pko*treat_aid +
                     lnpop + prec_gpcp + conflict_intensity + 
                     spatial_lag_osv + spatial_lag_pko + 
                     task_tamm + humaid_assist_tamm,
                   data = dat_no_IvoryCoast,
                   index = c("gid", "year"), model = "within")

```


```{r No Liberia}

dat_no_Liberia <-  dat %>%
  filter(!gwno == 450)

no_Liberia.1 <- plm(log_osv_forward1 ~ treat_pko + treat_aid + 
                     treat_pko*treat_aid +
                     lnpop + prec_gpcp + conflict_intensity + 
                     spatial_lag_osv + spatial_lag_pko +
                     task_tamm + humaid_assist_tamm,
                   data = dat_no_Liberia,
                   index = c("gid", "year"), model = "within")


no_Liberia.2 <- plm(osv_binary_forward1 ~ treat_pko + treat_aid + 
                     treat_pko*treat_aid +
                     lnpop + prec_gpcp + conflict_intensity + 
                     spatial_lag_osv + spatial_lag_pko + 
                     task_tamm + humaid_assist_tamm,
                   data = dat_no_Liberia,
                   index = c("gid", "year"), model = "within")

```



```{r No SierraLeone}

dat_no_SierraLeone <-  dat %>%
  filter(!gwno == 451)

no_SierraLeone.1 <- plm(log_osv_forward1 ~ treat_pko + treat_aid + 
                     treat_pko*treat_aid +
                     lnpop + prec_gpcp + conflict_intensity + 
                     spatial_lag_osv + spatial_lag_pko +
                     task_tamm + humaid_assist_tamm,
                   data = dat_no_SierraLeone,
                   index = c("gid", "year"), model = "within")


no_SierraLeone.2 <- plm(osv_binary_forward1 ~ treat_pko + treat_aid + 
                     treat_pko*treat_aid +
                     lnpop + prec_gpcp + conflict_intensity + 
                     spatial_lag_osv + spatial_lag_pko + 
                     task_tamm + humaid_assist_tamm,
                   data = dat_no_SierraLeone,
                   index = c("gid", "year"), model = "within")

```



```{r No Sudan}

dat_no_Sudan <-  dat %>%
  filter(!gwno == 625)

no_Sudan.1 <- plm(log_osv_forward1 ~ treat_pko + treat_aid + 
                     treat_pko*treat_aid +
                     lnpop + prec_gpcp + conflict_intensity + 
                     spatial_lag_osv + spatial_lag_pko +
                     task_tamm + humaid_assist_tamm,
                   data = dat_no_Sudan,
                   index = c("gid", "year"), model = "within")


no_Sudan.2 <- plm(osv_binary_forward1 ~ treat_pko + treat_aid + 
                     treat_pko*treat_aid +
                     lnpop + prec_gpcp + conflict_intensity + 
                     spatial_lag_osv + spatial_lag_pko + 
                     task_tamm + humaid_assist_tamm,
                   data = dat_no_Sudan,
                   index = c("gid", "year"), model = "within")

```


```{r TableA6}
#Table A6.1

modelsummary(list(no_Angola.1, no_Burundi.1, no_DRC.1,
                  no_IvoryCoast.1, no_Liberia.1, 
                  no_SierraLeone.1, no_Sudan.1), stars = TRUE)

#Table A6.2
modelsummary(list(no_Angola.2, no_Burundi.2, no_DRC.2,
                  no_IvoryCoast.2, no_Liberia.2, 
                  no_SierraLeone.2, no_Sudan.2), stars = TRUE)
```

